package everyday;

public class T1041 {
    public boolean isRobotBounded(String instructions) {
        int direct = 0;
        int[][] directActive = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
        int x = 0;
        int y = 0;
        for (int i = 0; i < instructions.length(); i++) {
            char c = instructions.charAt(i);
            if (c == 'L') {
                direct++;
                direct %= 4;
            } else if(c == 'R') {
                direct+=3;
                direct %= 4;
            }else{
                x+=directActive[direct][0];
                y+=directActive[direct][1];
            }
        }
        return direct != 0 || x == 0 && y == 0;
    }
}
